/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.skyeye.modeling.customerized;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
import org.skyeye.modeling.customerized.model.GPIOSoc;
import org.skyeye.modeling.customerized.model.LogicDiagram;
import org.skyeye.modeling.customerized.model.SPDTSwitch;
import org.skyeye.modeling.customerized.model.SPSTSwitch;
import org.skyeye.modeling.customerized.model.SimpleInput;
import org.skyeye.modeling.customerized.model.SimpleOutput;
import org.skyeye.modeling.customerized.model.Wire;
import org.skyeye.modeling.customerized.part.GPIOSocEditPart;
import org.skyeye.modeling.customerized.part.InputEditPart;
import org.skyeye.modeling.customerized.part.LogicDiagramEditPart;
import org.skyeye.modeling.customerized.part.OutputEditPart;
import org.skyeye.modeling.customerized.part.SwitchEditPart;
import org.skyeye.modeling.customerized.part.WireEditPart;

public class GraphicalPartFactory implements EditPartFactory {

	public EditPart createEditPart(EditPart context, Object model) {
		EditPart child = null;

		if (model instanceof Wire)
			child = new WireEditPart();
		else if (model instanceof GPIOSoc)
			child = new GPIOSocEditPart();
		else if (model instanceof SPSTSwitch || model instanceof SPDTSwitch)
			child = new SwitchEditPart();
		else if (model instanceof SimpleOutput)
			child = new OutputEditPart();
		else if (model instanceof SimpleInput)
			child = new InputEditPart();
		// Note that subclasses of LogicDiagram have already been matched above,
		// like Circuit
		else if (model instanceof LogicDiagram)
			child = new LogicDiagramEditPart();
		child.setModel(model);
		return child;
	}

}
